<template>
  <div class="dashboard">
    <el-row :gutter="24">
      <el-col :span="24">
        <h2 class="welcome-title">欢迎使用翰林书店管理系统</h2>
      </el-col>
    </el-row>
    
    <!-- 快捷操作区 -->
    <el-row :gutter="24">
      <el-col :span="8">
        <el-card class="quick-action" shadow="hover" @click="navigateTo('/book-retail')">
          <div class="stat-content">
            <el-icon><ShoppingCart /></el-icon>
            <div class="stat-info">
              <h3>图书销售</h3>
              <p>快速开始销售</p>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="8">
        <el-card class="quick-action" shadow="hover" @click="navigateTo('/inventory-management/book-inventory')">
          <div class="stat-content">
            <el-icon><Box /></el-icon>
            <div class="stat-info">
              <h3>图书入库</h3>
              <p>管理库存</p>
            </div>
          </div>
        </el-card>
      </el-col>
      <el-col :span="8">
        <el-card class="quick-action" shadow="hover" @click="navigateTo('/dealer-management')">
          <div class="stat-content">
            <el-icon><User /></el-icon>
            <div class="stat-info">
              <h3>经销商管理</h3>
              <p>管理供应商</p>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>

    <!-- 功能分组 -->
    <el-row :gutter="24" class="function-groups">
      <!-- 商品管理组 -->
      <el-col :span="12">
        <el-card class="function-group" shadow="hover">
          <template #header>
            <div class="group-header">
              <el-icon><Goods /></el-icon>
              <span>商品管理</span>
            </div>
          </template>
          <div class="group-content">
            <div class="function-item" @click="navigateTo('/goods-management/books')">
              <el-icon><Reading /></el-icon>
              <span>图书管理</span>
            </div>
            <div class="function-item" @click="navigateTo('/goods-management/goods')">
              <el-icon><Goods /></el-icon>
              <span>货品管理</span>
            </div>
          </div>
        </el-card>
      </el-col>
      
      <!-- 订单管理组 -->
      <el-col :span="12">
        <el-card class="function-group" shadow="hover">
          <template #header>
            <div class="group-header">
              <el-icon><Document /></el-icon>
              <span>订单管理</span>
            </div>
          </template>
          <div class="group-content">
            <div class="function-item" @click="navigateTo('/purchase-orders')">
              <el-icon><Sell /></el-icon>
              <span>进货订单</span>
            </div>
            <div class="function-item" @click="navigateTo('/shipping-orders')">
              <el-icon><ShoppingCart /></el-icon>
              <span>出货订单</span>
            </div>
          </div>
        </el-card>
      </el-col>
    </el-row>
  </div>
</template>

<script setup>
import { 
  ShoppingCart,
  Box,
  User,
  Goods,
  Document,
  Sell,
  Reading
} from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const navigateTo = (path) => {
  router.push(path)
}
</script>

<style scoped>
.dashboard {
  padding: 24px;
}

.welcome-title {
  margin: 0 0 24px;
  color: var(--el-text-color-primary);
  font-size: 24px;
  font-weight: 500;
}

.quick-action {
  margin-bottom: 24px;
  cursor: pointer;
  transition: all 0.3s;
}

.quick-action:hover {
  transform: translateY(-2px);
}

.stat-content {
  display: flex;
  align-items: center;
  padding: 20px;
}

.stat-content .el-icon {
  font-size: 32px;
  color: var(--el-color-primary);
  margin-right: 16px;
}

.stat-info h3 {
  margin: 0;
  font-size: 18px;
  color: var(--el-text-color-primary);
}

.stat-info p {
  margin: 4px 0 0;
  color: var(--el-text-color-secondary);
  font-size: 14px;
}

.function-groups {
  margin-top: 24px;
}

.function-group {
  height: 100%;
}

.group-header {
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 500;
}

.group-header .el-icon {
  margin-right: 8px;
  font-size: 18px;
}

.group-content {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  padding: 16px 0;
}

.function-item {
  display: flex;
  align-items: center;
  padding: 12px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
}

.function-item:hover {
  background-color: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
}

.function-item .el-icon {
  margin-right: 8px;
  font-size: 18px;
}

.function-item span {
  font-size: 14px;
}
</style>
